
SRC_FILES := $(wildcard *.c)


SRC_FILES += $(wildcard cJSON/*.c)
SRC_FILES += $(wildcard libvector/*.c)

# SRC_FILES += $(wildcard mongoose/*.c)
# SRC_FILES += $(wildcard http/*.c)
# SRC_FILES += $(wildcard sqlite/*.c)

# SRC_FILES += $(wildcard ortp_timer/*.c)
# SRC_FILES += $(wildcard usr_mgnt/*.c)
SRC_FILES += $(wildcard uuid/*.c)
# SRC_FILES += $(wildcard query_info/*.c)
SRC_FILES += $(wildcard mqtt/*.c)
SRC_FILES += $(wildcard twtimer/*.c)
SRC_FILES += $(wildcard rbtree/*.c)
# SRC_FILES += $(wildcard hecp/*.c)
# SRC_FILES += $(wildcard stream_mgnt/*.c)
CFLAGS += -I./include -I./libvector  -I./ortp_timer
CFLAGS += -I./mongoose   -I./cJSON  -I./sqlite  -I./rbtree
CFLAGS += -I./usr_mgnt 
ifeq ($(BUILD_MEMWATCH),y)
#SRC_FILES += $(TOPDIR)/ext/src/memwatch.c
endif

OBJ_FILES := $(patsubst %.c, %.o, $(SRC_FILES))
DEP_FILES := $(addsuffix .d,$(basename $(OBJ_FILES)))

EXEC := $(TARGET_PLATFORM)_$(TARGET_BOARD_NAME)_$(TARGET_PRODUCT_MODEL)_$(ARCH).bin

CFLAGS += -DVER_MAJ=$(VERSION_MAJOR) -DVER_MIN=$(VERSION_MINOR) -DVER_REV=$(VERSION_REVISION) -DVER_BID=$(VERSION_BUILD_ID)

CFLAGS += $(addsuffix include, -I./)

ifneq ($(MAKECMDGOALS),clean)
    -include $(DEP_FILES)
endif

target: $(OBJ_FILES) 
	$(CC) -o $(EXEC) $(OBJ_FILES) $(LDFLAGS)
	cp $(EXEC) $(TOPDIR)/release/release.bin
	@make clean

%.o:%.c
	$(CC) $(CFLAGS) -c $< -o $@

clean:
	rm -f $(OBJ_FILES) $(DEP_FILES)
